using System;
using UnityEngine;

public class GuideUI : MonoBehaviour
{
	public UIPanel curpanel;

	public Transform fingerflag;

	public Transform panelparent;

	public Transform curshow;

	public Transform oldparent;

	public int curstepindex;

	private bool isshow;

	private GameObject uiobj;

	public UIWidget hintinfowi;

	public UILabel hintlabel;

	public UIEventListener bgbtn;

	public void enable(bool isfirst)
	{
		if (uiobj == null)
		{
			uiobj = base.gameObject;
		}
		GlobalInf.menuuifirst = true;
		NGUITools.SetActive(uiobj, state: true);
		if (isfirst)
		{
			nextstep(null);
		}
		else
		{
			nextstep_1(null);
		}
	}

	public void showhighlight(UIEventListener showevent, Transform showtra)
	{
		showevent.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(showevent.onClick, new UIEventListener.VoidDelegate(nextstep));
		curshow = showtra;
		oldparent = showtra.parent;
		curshow.parent = panelparent;
		isshow = true;
		fingerflag.parent = curshow;
		switch (curstepindex)
		{
			case 0:
				fingerflag.localPosition = new Vector3(32f, 2.8f, 0f);
				fingerflag.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 94f));
				hintinfowi.alpha = 1f; hintinfowi.gameObject.SetActive(true);
				hintlabel.text = "欢迎来到天空战士！\n让我们先学会战斗!";
				hintinfowi.transform.localPosition = new Vector3(0f, 140f, 0f);
				break;
			case 1:
				fingerflag.localPosition = Vector3.zero;
				fingerflag.localRotation = Quaternion.Euler(Vector3.zero);
				hintinfowi.alpha = 0f; hintinfowi.gameObject.SetActive(false);
				hintlabel.gameObject.SetActive(false);
				break;
			case 2:
				fingerflag.localPosition = new Vector3(-7f, -50f, 0f);
				fingerflag.localRotation = Quaternion.Euler(Vector3.zero);
				break;
			case 3:
				fingerflag.localPosition = new Vector3(0f, -30f, 0f);
				fingerflag.localRotation = Quaternion.Euler(Vector3.zero);
				break;
		}
		NGUITools.SetActive(curshow.gameObject, state: false);
		NGUITools.SetActive(curshow.gameObject, state: true);
	}

	public void nextstep(GameObject btn)
	{
		if (isshow)
		{
			curshow.parent = oldparent;
			NGUITools.SetActive(curshow.gameObject, state: false);
			curstepindex++;
		}
		switch (curstepindex)
		{
			case 0:
				showhighlight(MenuUIController.instance.mainui.battlebtn, MenuUIController.instance.mainui.battlebtn.transform);
				Platform.flurryEvent_guide_first(0);
				break;
			case 1:
				showhighlight(MenuUIController.instance.battleui.islandbtns[0], MenuUIController.instance.battleui.islandflags[0].transform);
				Platform.flurryEvent_guide_first(1);
				break;
			case 2:
				showhighlight(MenuUIController.instance.levelui.levelitems[0].levelbtn, MenuUIController.instance.levelui.levelitems[0].levelbtn.transform);
				Platform.flurryEvent_guide_first(2);
				break;
			case 3:
				showhighlight(MenuUIController.instance.startui.startbtn, MenuUIController.instance.startui.startbtn.transform);
				Platform.flurryEvent_guide_first(3);
				break;
		}
		if (curstepindex == 4)
		{
			disable();
			Platform.flurryEvent_guide_first(4);
		}
	}

	public void showhighlight_1(UIEventListener showevent, Transform showtra)
	{
		showevent.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(showevent.onClick, new UIEventListener.VoidDelegate(nextstep_1));
		curshow = showtra;
		oldparent = showtra.parent;
		curshow.parent = panelparent;
		isshow = true;
		switch (curstepindex)
		{
			case 0:
				fingerflag.parent = curshow;
				fingerflag.localPosition = new Vector3(0f, -26f, 0f);
				fingerflag.localRotation = Quaternion.Euler(Vector3.zero);
				hintinfowi.alpha = 1f; hintinfowi.gameObject.SetActive(true);
				hintlabel.text = "不过现在让我们先看看装备吧";
				break;
			case 1:
				fingerflag.parent = panelparent;
				NGUITools.SetActive(fingerflag.gameObject, state: true);
				fingerflag.position = MenuUIController.instance.upgradeui.weaponitem[0].upgradebtn.transform.position;
				fingerflag.localPosition += new Vector3(0f, -26f, 0f);
				fingerflag.localRotation = Quaternion.Euler(Vector3.zero);
				hintinfowi.alpha = 1f; hintinfowi.gameObject.SetActive(true);
				hintlabel.text = "您可以在这里更换或升级装备";
				break;
		}
		NGUITools.SetActive(curshow.gameObject, state: false);
		NGUITools.SetActive(curshow.gameObject, state: true);
	}

	public void nextstep_1(GameObject btn)
	{
		if (isshow)
		{
			curshow.parent = oldparent;
			NGUITools.SetActive(curshow.gameObject, state: false);
			curstepindex++;
		}
		switch (curstepindex)
		{
			case 0:
				showhighlight_1(MenuUIController.instance.garageui.upgradebtn, MenuUIController.instance.garageui.upgradebtn.transform);
				Platform.flurryEvent_guide_first(10);
				break;
			case 1:
				showhighlight_1(bgbtn, bgbtn.transform);
				Platform.flurryEvent_guide_first(11);
				break;
		}
		if (curstepindex == 2)
		{
			disable();
			Platform.flurryEvent_guide_first(12);
		}
	}

	public void disable()
	{
		NGUITools.SetActive(uiobj, state: false);
		GlobalInf.menuuifirst = false;
		MenuPlayerprefs.instance.setmenufirst();
	}
}
